/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import pojo.TinhTrangPoJo;
import util.DataProvider;

/**
 *
 * @author Kanet
 */
public class TinhTrangDao {
    
      
    public static ArrayList<TinhTrangPoJo> laydanhsachTinhTrang()
    {
        ArrayList<TinhTrangPoJo> arr = new ArrayList<TinhTrangPoJo>();
        String sql = "SELECT * FROM tinhtrang";
        DataProvider dp = new DataProvider();
        dp.open();
        
        try{
            ResultSet rs = dp.executeQuery(sql);
            while (rs.next()){
                TinhTrangPoJo tinhtrang = new TinhTrangPoJo();
                tinhtrang.setIdTinhTrang(rs.getInt("idTinhTrang"));
                tinhtrang.setTenTinhTrang(rs.getString("tenTinhTrang"));
                arr.add(tinhtrang);
            }            
        }
        catch(SQLException ex){
            System.out.println(ex.getMessage());                        
        }
        dp.close();
        return arr;
    }
}
